<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">

		//{a:"a",b:"b",wife:{name:"xxx"}}
		Object.deepFreeze = function(obj) {
		  //得到对象的直接属性名
		  var propNames = Object.getOwnPropertyNames(obj);
		  propNames.forEach(function(name){
		    var prop = obj[name];
		    if (typeof prop == 'object' && prop !== null) {
		      //prop:{name:"xxx"}
		      Object.deepFreeze(prop);
		    }
		  });

		  return Object.freeze(obj);
		}
	</script>
</html>
